<template>
	<view class="custom-navbar">
		<button v-if="hasBack" class="custom-back-button" @click="goBack">返回</button>
		<view class="title">{{ title }}</view>
	</view>
</template>

<script>
	export default {
		name: 'custom-navbar-black',
		props: {
			title: {
				type: String,
				default: ''
			},
			hasBack: {
				type: Boolean,
				default: true // 默认显示返回按钮
			}
		},
		methods: {
			goBack() {
				  const pages = getCurrentPages();
				      console.log('当前页面栈:', pages); // 日志调试
				this.$tab.reLaunch('/pages/index')
				//uni.navigateBack();
			}
		}
	};
</script>

<style scoped>
	.custom-navbar {
		position: fixed;
		top: 0;
		left: 0;
		width: 36%;
		display: flex;
		align-items: center;
		/* background-color: #ff5722; */
		/* 修改背景颜色 */
		color: #ffffff;
		/* 修改字体颜色 */
		padding: 10px;
		z-index: 1000;
		/* 确保导航栏在所有元素之上 */
	}

	.custom-back-button {
		background: none;
		text-indent: -99em;
		width: 60px;
		height: 60px;
		border: none;
		color: #ffffff;
		font-size: 16px;
		padding: 0px;
		cursor: pointer;
		background: url('/static/images/back2.png') no-repeat;
		background-size: cover;
		margin-top: 21px;
	}

	.title {
		margin-left: 10px;
		font-size: 16px;
		/* 修改标题字体大小 */
		font-weight: bold;
		/* 修改标题字体粗细 */
	}
</style>